package com.yulong.web.server.Impl;

import com.yulong.model.pojo.UmsResource;
import com.yulong.web.mapper.UmsResourceMapper;
import com.yulong.web.server.UmsResourcServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class UmsResourcServerImpl implements UmsResourcServer {


    @Autowired
    private UmsResourceMapper umsResourceMapper;


    /**
     * 分页查询资源列表
     *
     * @param name       资源名
     * @param url        资源路径
     * @param categoryId 资源分类id
     * @return
     */
    @Override
    public List<UmsResource> list(String name, String url, Long categoryId) {
        return umsResourceMapper.list(name,url,categoryId);
    }

    /**
     * 删除资源
     *
     * @param id
     * @return
     */
    @Override
    public Integer delete(Long id) {
        return umsResourceMapper.delete(id);
    }

    /**
     * 更新资源分类
     *
     * @param umsResource
     * @return
     */
    @Override
    public Integer update(UmsResource umsResource) {
        umsResource.setCreateTime(new Date());
        return umsResourceMapper.update(umsResource);
    }

    /**
     * 添加资源分类
     *
     * @param umsResource
     * @return
     */
    @Override
    public Integer create(UmsResource umsResource) {
        umsResource.setCreateTime(new Date());
        return umsResourceMapper.create(umsResource);
    }
}
